<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <textarea id='demo' cols='30' rows="='10"></textarea>
</body>
<script>
  var demo = document.querySelector('#demo')

  // demo.onkeydown = function (e) {
  //   var e = e || window.event;
  //   console.log(e);
  //   console.log(e.key, e.keyCode);


  //   // return false;
  // }

  demo.onkeypress = function (e) {
    var e = e || window.event;
    console.log(e);
    console.log(e.key, e.keyCode);


    // return false;
  }

</script>

</html>